<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Products extends MY_Controller {
     public function __construct()
     {
        parent::__construct();
        $this->load->vars('title',$this->title);
     }
	public function index()
	{
		$items=$this->category_product_model->getAll(100,0,1);
        $this->load->vars('items',$items);
	}
    public function detail()
    {
        $this->load->model('admin/product_model');
        $alias=$this->uri->segment(2);
        $items=$this->product_model->getProductByAlias($alias);
        $this->load->vars('items',$items);
    }
    public function listproduct()
    {
        $this->load->model('admin/product_model');
        $this->load->model('admin/category_product_model');
        $type=$this->uri->segment(2);
        $cat=$this->category_product_model->getCategoryIdByAlias($type);
        $catid=$cat->category_product_id;
        $catname=$cat->category_product_name;
        $items=$this->product_model->getProductByCategory($catid);
        $this->load->vars('items',$items);
        $this->load->vars('catname',$catname);
    }
}

